import json 
import random 

def read_try_list():
    global try_list
    with open("try_list.json","r",encoding="utf8") as rfp:
        try_list = json.loads(rfp.read() )
    return try_list

try_list = read_try_list()
print(f'{len(try_list)=}')



def create_pass_list():
    global try_list
    key1 =['keylist1'] ## some key your can remember in passcode... 
    key2 =['keylist2']
    key3 = ['keylist3']

    prefix = ['prefix_list']
    key4= ['keylist4']

    dict_list =[] 
    def order(order):
        a ,b ,c,d = order     
        for aa in a :
            for bb in b: 
                for cc in c:
                    for dd in d:
                        dict_list.append(aa+bb+cc+dd)
    # order( (prefix, key4, key2,key3) )
    # order((key1,key2,key3,key4))
    # order((key3,key2,key1,key4))
    order( random.sample([key1,key2,key3,key4,prefix],4 ))  ## 

    pass_list = [key.strip() for key in dict_list if key not in try_list]
    
    return pass_list

def write_pass_list_to_file(pass_list):
    with open("dict_list.txt","w",encoding="utf8") as wfp:
        wfp.writelines('\n'.join(pass_list))
    

def save_try_list():
    global try_list
    s = json.dumps(try_list,indent=4, ensure_ascii=False)
    with open('try_list.json',"w",encoding="utf8") as wfp:
        wfp.write(s)

pass_list = create_pass_list()
print(f'{len(pass_list)=}' ) 
try_list = try_list + pass_list
write_pass_list_to_file(pass_list)

save_try_list()

